package com.code.day18;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;

public class Demo12HashSet {
    public static void main(String[] args) {
        LinkedHashSet<String> hashSet = new LinkedHashSet<>();
        hashSet.add("hello");
        hashSet.add("张三");
        hashSet.add("李四");
        hashSet.add("王五");
        hashSet.add("赵六");
        hashSet.add("田七");
        hashSet.add("朱八");
        hashSet.add("张三");

        for (String s : hashSet) {
            System.out.println(s);
        }
        Iterator<String> iterator = hashSet.iterator();
        while(iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
        }
    }
}
